'use strict';
module.exports = (sequelize, DataTypes) => {
  const User = sequelize.define('User', {
    username: DataTypes.STRING,
    password: DataTypes.STRING,
    mobile: DataTypes.STRING,
    email: DataTypes.STRING
  }, {});
  User.associate = function(models) {
    // associations can be defined here
    User.hasMany(models.Post, {foreignKey: 'author', sourceKey: 'id'});
    User.hasMany(models.Cart);
    User.belongsToMany(models.CorporateEntity, {through: 'CorporateEntityUser'});
    User.belongsToMany(models.Role, {through: 'RoleUser'});
  };
  return User;
};